package com.pengtu.entity.detect;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.pengtu.utils.MathsUtils;

/**
 * 
 * 路面工程
 * Surfacespot.
 */
@Entity
@Table(name = "S_Q_DETECT_SURFACESPOT")
public class SurfaceSpot {

	/**
	 * serialVersionUID:TODO
	 * 
	 * @since 1.0.0
	 */

	private static final long serialVersionUID = 1L;
	private String projectId; // 工程
	private Integer countF301;//   沥青路面弯沉﹡抽检点数 
	private Integer passF301;//    沥青路面弯沉﹡合格点数
	private Integer countF302;//   沥青路面车辙﹡抽检点数 
	private Integer passF302;//    沥青路面车辙﹡合格点数
	private Integer countF303;//   混凝土路面强度﹡抽检点数 
	private Integer passF303;//    混凝土路面强度﹡合格点数
	private Integer countF304;//   沥青路面压实度﹡抽检点数 
	private Integer passF304;//    沥青路面压实度﹡合格点数
	private Integer countF305;//   路面平整度﹡抽检点数 
	private Integer passF305;//    路面平整度﹡合格点数
	private Integer countF306;//   路面厚度﹡抽检点数 
	private Integer passF306;//    路面厚度﹡合格点数
	private Integer countF307;//   混凝土路面相邻板高差*抽检点数 
	private Integer passF307;//    混凝土路面相邻板高差*合格点数
	private Integer countF308;//   路面抗滑*抽检点数 
	private Integer passF308;//    路面抗滑*合格点数
	private Integer countF309;//   路面横坡抽*检点数 
	private Integer passF309;//    路面横坡*合格点数
	private Integer countF310;//   路面基层强度及厚度*抽检点数 
	private Integer passF310;//    路面基层强度及厚度*合格点数
	private Date reportdate;
	private String remark;
	private SpotReport spotReport;
	private String id;
	private String groupBy;
	public SurfaceSpot(Long countF301, Long passF301, Long countF302,
			Long passF302, Long countF303, Long passF303, Long countF304,
			Long passF304, Long countF305, Long passF305, Long countF306,
			Long passF306, Long countF307, Long passF307, Long countF308,
			Long passF308, Long countF309, Long passF309, Long countF310,
			Long passF310,String groupBy){
		this.countF301 = countF301 == null ? null : countF301.intValue();
		this.passF301 = passF301 == null ? null : passF301.intValue();
		this.countF302 = countF302 == null ? null : countF302.intValue();
		this.passF302 = passF302 == null ? null : passF302.intValue();
		this.countF303 = countF303 == null ? null : countF303.intValue();
		this.passF303 = passF303 == null ? null : passF303.intValue();
		this.countF304 = countF304 == null ? null : countF304.intValue();
		this.passF304 = passF304 == null ? null : passF304.intValue();
		this.countF305 = countF305 == null ? null : countF305.intValue();
		this.passF305 = passF305 == null ? null : passF305.intValue();
		this.countF306 = countF306 == null ? null : countF306.intValue();
		this.passF306 = passF306 == null ? null : passF306.intValue();
		this.countF307 = countF307 == null ? null : countF307.intValue();
		this.passF307 = passF307 == null ? null : passF307.intValue();
		this.countF308 = countF308 == null ? null : countF308.intValue();
		this.passF308 = passF308 == null ? null : passF308.intValue();
		this.countF309 = countF309 == null ? null : countF309.intValue();
		this.passF309 = passF309 == null ? null : passF309.intValue();
		this.countF310 = countF310 == null ? null : countF310.intValue();
		this.passF310 = passF310 == null ? null : passF310.intValue();
		this.groupBy = groupBy;
	}
	
	public SurfaceSpot(Long countF301, Long passF301, Long countF302,
			Long passF302, Long countF303, Long passF303, Long countF304,
			Long passF304, Long countF305, Long passF305, Long countF306,
			Long passF306, Long countF307, Long passF307, Long countF308,
			Long passF308, Long countF309, Long passF309, Long countF310,
			Long passF310){
		this.countF301 = countF301 == null ? null : countF301.intValue();
		this.passF301 = passF301 == null ? null : passF301.intValue();
		this.countF302 = countF302 == null ? null : countF302.intValue();
		this.passF302 = passF302 == null ? null : passF302.intValue();
		this.countF303 = countF303 == null ? null : countF303.intValue();
		this.passF303 = passF303 == null ? null : passF303.intValue();
		this.countF304 = countF304 == null ? null : countF304.intValue();
		this.passF304 = passF304 == null ? null : passF304.intValue();
		this.countF305 = countF305 == null ? null : countF305.intValue();
		this.passF305 = passF305 == null ? null : passF305.intValue();
		this.countF306 = countF306 == null ? null : countF306.intValue();
		this.passF306 = passF306 == null ? null : passF306.intValue();
		this.countF307 = countF307 == null ? null : countF307.intValue();
		this.passF307 = passF307 == null ? null : passF307.intValue();
		this.countF308 = countF308 == null ? null : countF308.intValue();
		this.passF308 = passF308 == null ? null : passF308.intValue();
		this.countF309 = countF309 == null ? null : countF309.intValue();
		this.passF309 = passF309 == null ? null : passF309.intValue();
		this.countF310 = countF310 == null ? null : countF310.intValue();
		this.passF310 = passF310 == null ? null : passF310.intValue();
	}
	private Date createDate; // 创建时间


	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(length = 48)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(nullable = false, updatable = false, name = "CREATEDATE")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@OneToOne(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
	@JoinColumn(name = "SID")
	public SpotReport getSpotReport() {
		return spotReport;
	}

	public void setSpotReport(SpotReport spotReport) {
		this.spotReport = spotReport;
	}

	public SurfaceSpot() {
	}

	@Column(name = "PID")
	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}

	@Column(name = "COUNT_F301")
	public Integer getCountF301() {
		return this.countF301;
	}

	public void setCountF301(Integer countF301) {
		this.countF301 = countF301;
	}

	@Column(name = "PASS_F301")
	public Integer getPassF301() {
		return this.passF301;
	}

	public void setPassF301(Integer passF301) {
		this.passF301 = passF301;
	}

	@Column(name = "COUNT_F302")
	public Integer getCountF302() {
		return this.countF302;
	}

	public void setCountF302(Integer countF302) {
		this.countF302 = countF302;
	}

	@Column(name = "PASS_F302")
	public Integer getPassF302() {
		return this.passF302;
	}

	public void setPassF302(Integer passF302) {
		this.passF302 = passF302;
	}

	@Column(name = "COUNT_F303")
	public Integer getCountF303() {
		return this.countF303;
	}

	public void setCountF303(Integer countF303) {
		this.countF303 = countF303;
	}

	@Column(name = "PASS_F303")
	public Integer getPassF303() {
		return this.passF303;
	}

	public void setPassF303(Integer passF303) {
		this.passF303 = passF303;
	}

	@Column(name = "COUNT_F304")
	public Integer getCountF304() {
		return this.countF304;
	}

	public void setCountF304(Integer countF304) {
		this.countF304 = countF304;
	}

	@Column(name = "PASS_F304")
	public Integer getPassF304() {
		return this.passF304;
	}

	public void setPassF304(Integer passF304) {
		this.passF304 = passF304;
	}

	@Column(name = "COUNT_F305")
	public Integer getCountF305() {
		return this.countF305;
	}

	public void setCountF305(Integer countF305) {
		this.countF305 = countF305;
	}

	@Column(name = "PASS_F305")
	public Integer getPassF305() {
		return this.passF305;
	}

	public void setPassF305(Integer passF305) {
		this.passF305 = passF305;
	}

	@Column(name = "COUNT_F306")
	public Integer getCountF306() {
		return this.countF306;
	}

	public void setCountF306(Integer countF306) {
		this.countF306 = countF306;
	}

	@Column(name = "PASS_F306")
	public Integer getPassF306() {
		return this.passF306;
	}

	public void setPassF306(Integer passF306) {
		this.passF306 = passF306;
	}

	@Column(name = "COUNT_F307")
	public Integer getCountF307() {
		return this.countF307;
	}

	public void setCountF307(Integer countF307) {
		this.countF307 = countF307;
	}

	@Column(name = "PASS_F307")
	public Integer getPassF307() {
		return this.passF307;
	}

	public void setPassF307(Integer passF307) {
		this.passF307 = passF307;
	}

	@Column(name = "COUNT_F308")
	public Integer getCountF308() {
		return this.countF308;
	}

	public void setCountF308(Integer countF308) {
		this.countF308 = countF308;
	}

	@Column(name = "PASS_F308")
	public Integer getPassF308() {
		return this.passF308;
	}

	public void setPassF308(Integer passF308) {
		this.passF308 = passF308;
	}

	@Column(name = "COUNT_F309")
	public Integer getCountF309() {
		return this.countF309;
	}

	public void setCountF309(Integer countF309) {
		this.countF309 = countF309;
	}

	@Column(name = "PASS_F309")
	public Integer getPassF309() {
		return this.passF309;
	}

	public void setPassF309(Integer passF309) {
		this.passF309 = passF309;
	}

	@Column(name = "COUNT_F310")
	public Integer getCountF310() {
		return this.countF310;
	}

	public void setCountF310(Integer countF310) {
		this.countF310 = countF310;
	}

	@Column(name = "PASS_F310")
	public Integer getPassF310() {
		return this.passF310;
	}

	public void setPassF310(Integer passF310) {
		this.passF310 = passF310;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "REPORTDATE")
	public Date getReportdate() {
		return this.reportdate;
	}

	public void setReportdate(Date reportdate) {
		this.reportdate = reportdate;
	}

	@Column(name = "REMARK")
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Transient
	public Double getPassrateF301() {
		Double a = MathsUtils.div("2",getPassF301(), getCountF301(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF302() {
		Double a = MathsUtils.div("2",getPassF302(), getCountF302(),0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF303() {
		Double a = MathsUtils.div("2",getPassF303(), getCountF303(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF304() {
		Double a = MathsUtils.div("2",getPassF304(), getCountF304(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF305() {
		Double a = MathsUtils.div("2",getPassF305(), getCountF305(),0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF306() {
		Double a = MathsUtils.div("2",getPassF306(), getCountF306(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF307() {
		Double a = MathsUtils.div("2",getPassF307(), getCountF307(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF308() {
		Double a = MathsUtils.div("2",getPassF308(), getCountF308(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF309() {
		Double a = MathsUtils.div("2",getPassF309(), getCountF309(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public Double getPassrateF310() {
		Double a = MathsUtils.div("2",getPassF310(), getCountF310(), 0.01);
		if(a==0){
			a = null;
		}
		return a;
	}

	@Transient
	public double getCountF300() {
		return MathsUtils.sum(getCountF301(), getCountF302(), getCountF303(),
				getCountF304(), getCountF305(), getCountF306(), getCountF307(),
				getCountF308(), getCountF309(), getCountF310());
	}

	@Transient
	public double getPassF300() {
		return MathsUtils.sum(getPassF301(), getPassF302(), getPassF303(),
				getPassF304(), getPassF305(), getPassF306(), getPassF307(),
				getPassF308(), getPassF309(), getPassF310());
	}

	@Transient
	public double getPassrateF300() {
		if(getCountF300()==0){
			return 0;}
		else {
		return MathsUtils.div("2",getPassF300(),getCountF300(), 0.01);
	}
	}
	@Transient
	public String getGroupBy() {
		return this.groupBy;
	}
}
